<script>
$(function(){
<?php if (empty($phone)){ ?>
$('.phonereg-t1').width(sWidth).height(_rate*578);
$('.phonereg-phone').width(_rate*440).height(_rate*70).css({"top":_rate*191, "left":_rate*242});
$('.phonereg-code').width(_rate*260).height(_rate*70).css({"top":_rate*280, "left":_rate*246});
$('.phonereg-yzbtn').width(_rate*200).height(_rate*80).css({"top":_rate*270, "left":_rate*510,'line-height':_rate*80+'px'});
$('.phonereg-btn').width(_rate*570).height(_rate*120).css({"top":_rate*400, "left":_rate*90});

$('.userreg-t1').width(sWidth).height(_rate*1006);
$('.userreg-phone').width(_rate*440).height(_rate*70).css({"top":_rate*210, "left":_rate*242});
$('.userreg-name').width(_rate*440).height(_rate*70).css({"top":_rate*371, "left":_rate*242});
$('.userreg-yu').width(_rate*240).height(_rate*70).css({"top":_rate*461, "left":_rate*442});
$('.userreg-yu2').width(_rate*240).height(_rate*70).css({"top":_rate*601, "left":_rate*442}); 
$('.userreg-c1').width(_rate*59).css({"top":_rate*698, "left":_rate*48});
$('.userreg-tiaokuan').width(_rate*320).height(_rate*90).css({"top":_rate*698, "left":_rate*348});
$('.userreg-btn').width(_rate*670).height(_rate*170).css({"top":_rate*801, "left":_rate*42});
$(".content-bg").height(_rate*1634);
<?php }else{ ?>
$('.gonggaobox').width(sWidth).height(_h);
$('.gonggaoLogo').width(_rate*675).height(_rate*207).css({"left":0});
$('.closegonggao').width(_rate*130).height(_rate*120).css({"top":0,"right":_rate*30});
$('.ggpic').width(_rate*675).css({"top":_rate*206,"left":0});
$('.ggscrollbox').css({"top":_rate*25,"bottom":_rate*25});
 
 

$('.ggbox02').width(_rate*520).css({"top":_rate*326, "left":_rate*78,"bottom":_rate*50,"border-radius":_rate*20});
$('.layerName0').width(_rate*220).height(_rate*139).css({"left":_rate*210});
$('.layerScore0').width(_rate*100).height(_rate*139).css({"left":_rate*424});
window.setTimeout(function(){
  $(".gamebox").fadeIn();
}, 400);



<?php } ?>  
 

 
wx.config({
    appId: '<?php echo $signPackage["appId"];?>',
    timestamp: '<?php echo $signPackage["timestamp"];?>',
    nonceStr: '<?php echo $signPackage["nonceStr"];?>',
    signature: '<?php echo $signPackage["signature"];?>',
    jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData', 'showMenuItems', 'hideMenuItems']
});
wx.ready(function () {
		var _title='标题临时文案';
		var _link='http://climb-game.51wom.com/?f=<?php echo $openid; ?>';
		var _imgUrl='http://climb-game.51wom.com/images/64.jpg';
			wx.updateAppMessageShareData({
			    title: _title, 
			    desc: '活动描述临时文案', 
			    link: _link, 
			    imgUrl: _imgUrl, 
			    success: function () {
			    }
			  })
			 wx.updateTimelineShareData({ 
                  title: '活动描述临时文案', 
                  link: _link, 
                  imgUrl: _imgUrl, 
                  success: function () {
                  }
                });
			_bgm.play();
			_isPlay=true;
			$(".pBgm1").hide();
			$(".pBgm2").show();

}); 
window.setTimeout(function(){
  $.post("api/?c=pv", {op:'<?php echo $openid ?>',cookieid:_cookieId}, function(data){}, "json");
}, 700);

 
document.addEventListener("WeixinJSBridgeReady", function(){_bgm.play()}, false);


});


 

<?php if (!empty($phone)){ ?>
   window.setTimeout(function(){
  _setEveClick('gonggao');
}, 600);


<?php }else{ ?>
 
$('#userreg-d1').on('click', function () {
        weui.datePicker({
            start: 1990,
            end: 2025,
            onConfirm: function (result) {
               $('#userreg-d1').val(result[0].value+'-'+result[1].value+'-'+result[2].value);
            },
            title: '选择日期'
        });
    });
$('#userreg-d2').on('click', function () {
        weui.datePicker({
            start: 1990,
            end: 2025,
            onConfirm: function (result) {
               $('#userreg-d2').val(result[0].value+'-'+result[1].value+'-'+result[2].value);
            },
            title: '选择日期'
        });
    });
var _isagreeUserReg=false;
$(".userreg-c1").click(function(){
	if(false == _isagreeUserReg){
        _isagreeUserReg=true;
        $(".userreg-c1").attr("src",'images/user-reg-chek1.png');
	}else{
		_isagreeUserReg=false;
		$(".userreg-c1").attr("src",'images/user-reg-chek2.png');
	}
});
function checkPhone(phone){ 
  if(!(/^1[2|3|4|5|6|7|8|9]\d{9}$/.test(phone))){ 
  return false; 
  }else{
    return true;
    } 
}
$(".phonereg-yzbtn").click(function(){
     var _this = $(this);
     var _tel=$(".phonereg-phone").val();
     if(_tel==""){
      icom.alert("手机号不能为空")
      return;
     }
     if(false == checkPhone(_tel)){
      icom.alert("请输入正确的手机号")
      return;
     }
     djsfn(_this);
     $.post("api/?c=sms", {p:_tel, op:_openid}, function(data){
          
      }, "json"); 
     
  });

function djsfn(_this){
    sended=true;
    var num=10;
    _this.addClass("sendActive");
    _this.html(""+num+"s");
    sendTimer=setInterval(function (){
      num--;
      if(num==0){
        _this.removeClass("sendActive").html("获取验证码");
        sended=false;
        clearInterval(sendTimer);
        }else{
          _this.html(""+num+"s");
          }
      
      },1000)
    
    
  }
 
$(".phonereg-btn").click(function(){
	var _tel=$(".phonereg-phone").val();
	var _code=$(".phonereg-code").val();
	if('' == _tel){
		icom.alert("请输入手机号")
		return;
	}
  if(false == checkPhone(_tel)){
      icom.alert("请输入正确的手机号")
      return;
  }
	if('' == _code){
		icom.alert("请输入验证码")
		return;
	}
 
	$.post("api/?c=ishui", {p:_tel, code:_code,op:'<?php echo $openid ?>'}, function(data){
			if('y' == data.s){
         if('gogo' == data.t){
            icom.alert("注册成功");
            window.location.href="http://climb-game.51wom.com/";
            return;
         }else{
          $(".userreg-phone").html(_tel);
          $(".phonereg").hide();
          $(".userreg").show();
         }
				 
          
			}else{
				 if ('phone' == data.t) {
				 	icom.alert("手机号格式不正确");
		            return;
				 }
         if ('sms' == data.t) {
          icom.alert("验证码不正确");
                return;
         }
			}
		}, "json");	
   });

   $(".userreg-btn").click(function(){
   	   var _tel=$(".phonereg-phone").val();
   	   var _name=$(".userreg-name").val();
   	   var _yu=$(".userreg-yu").val();
   	   var _yu2=$(".userreg-yu2").val();
       
       var timeA = new Date(_yu);
       console.log(_yu2);
       
       
   	  if('' == _tel){
        $(".userreg").hide();
	    $(".phonereg").show();
   	   	return;
   	   }
   	   if ('' == _name) {
   	   	 icom.alert("请输入姓名")
		     return;
   	   }
   	   if ('' == _yu) {
   	   	 icom.alert("请输入您的预产期或宝宝生日")
		 return;
   	   }
       if ('' != _yu2) {
         var timeB = new Date(_yu2);
         var _tmpCha=Math.floor((timeB - timeA)/1000/60/60/ 24);
         console.log(_tmpCha);
         if (_tmpCha < 0) {
               icom.alert("二胎预产期，时间有误")
               return;
         }
         if (_tmpCha < 270) {
               icom.alert("二胎与一胎生日差，应大于270天")
               return;
         }
       }
   	   if(false == _isagreeUserReg){
   	   	 icom.alert("请接受会员服务条款")
		     return;
   	   }
   	   $.post("api/?c=doreg", {p:_tel,name:_name,yu:_yu,yu2:_yu2, op:'<?php echo $openid ?>'}, function(data){
			if('y' == data.s){

				   window.location.reload();

			}else{
         icom.alert("注册失败，请检查手机格式")
         return;
      }
		}, "json");	

   
	  

});

 <?php } ?>   

</script>